package net.wendal.base.util;

import java.util.LinkedList;
import java.util.Queue;

/**
 * Created by y on 2017/2/9.
 */
public class QueueBehavior {

    private static int count = 3;

    static <T> void test(Queue<T> queue, Generator<T> gen) {

        for (int i = 0; i < count; i++)
            queue.offer(gen.next());
        while (queue.peek() != null)
            System.out.println(queue.remove() + "");

    }

    static class Gen implements Generator<String> {

        String[] s = ("one two three").split(" ");

        int i;

        @Override
        public String next() {
            return s[i++];
        }
    }

    public static void main(String[] args) {
        test(new LinkedList<String>(), new Gen());
    }
}
